package com.geektime.tdd.test;

import java.math.BigDecimal;

/**
 * 计算方法
 */
public class PricingService {

    private final ProductVerifier productVerifier;

    private final ProductReport productReport;

    public PricingService(ProductVerifier productVerifier, ProductReport productReport) {
        this.productVerifier = productVerifier;
        this.productReport = productReport;
    }


    public BigDecimal calculatePrice(String productName) {
        if (productVerifier.isCurrentlyInStockOfCompetitor(productName)) {
            productReport.notify(productName);
            return new BigDecimal("99.99");
        }
        return new BigDecimal("149.99");
    }
}

